package fr.umlv.galcon.planet;

import java.util.TimerTask;

import fr.umlv.galcon.game.GalconManager;
import fr.umlv.galcon.item.ItemListSingleton;
import fr.umlv.galcon.player.PlayerType;

/**
 * Timer which raise the stock of all planets
 */
public class StockTask extends TimerTask {

    @Override
    public void run() {
	if (!GalconManager.getEndGame() && !GalconManager.isOver()) {
	    for (Planet p : ItemListSingleton.getInstance().getPlanetList()) {
		if (p.getOwner().getPlayerType() != PlayerType.NEUTRAL) {
		    p.getStock().raiseStock();
		}
	    }
	} else {
	    cancel();
	}

    }
}
